#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

//origin and reverse LCS(subsequence)
// 432xx34
// 43xx234
// dp[i][j] = s1[i] == s2[j] ?
//            dp[i-1][j-1] + 1 : max(dp[i-1][j], dp[i][j-1]) 
// dp[i][j] LCS end with i
int main()
{
    int n;
    cin >> n;
    string s1;
    cin >> s1;
    string s2(s1);
    reverse(s2.begin(), s2.end());

    vector<int> dp[2]={vector<int>(n + 1, 0),vector<int>(n + 1, 0)};
    int ans = 0;
    int k = 0;
    for (int i = 0; i < n; i++)
    {
        k = 1-k;
        for (int j = 0; j < n; j++)
        {
            if (s1[i] == s2[j])
                dp[k][j + 1] = dp[1-k][j] + 1;
            else
                dp[k][j + 1] = max(dp[1-k][j + 1], dp[k][j]);
            //ans = max(ans, dp[k][j + 1]);
        }
    }
    cout << n - ans;

    return 0;
}
/*
7
432dd34

5
Ab3bd

*/